package com.delivery.deliverysystem.controller;

import com.delivery.deliverysystem.common.ResponseCode;
import com.delivery.deliverysystem.common.ServerResponse;
import com.delivery.deliverysystem.service.BackendSystemService;
import com.delivery.deliverysystem.util.LocalIpUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 后台控制类
 */
@RestController
@RequestMapping("/backend")
@Api(tags = "后台管理接口")
public class BackendSystemController {

    @Autowired
    private BackendSystemService backendSystemService;


    @PostMapping("/restore")
    @ApiOperation(value = "恢复数据库数据", response = ServerResponse.class, httpMethod = "POST")
    public ServerResponse restore(@RequestParam("file") MultipartFile file) {
        if (file.isEmpty()) {
            return ServerResponse.createByError("上传的文件为空");
        }
        return backendSystemService.restore(file);
    }

}
